package C;

import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class C66 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        int[] nums = Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::parseInt)
                .sorted().toArray();
//        System.out.println(Arrays.toString(nums));
        System.out.println(getResult(nums));
    }

    public static int getResult(int[] nums) {
        PriorityQueue<Integer> pq = new PriorityQueue<>((a,b)->b-a);
        for (int i = 0; i < nums.length; i++) {
            pq.offer(nums[i]);
        }
        int x=0,y=0,z=0;
        while(pq.size()>2) {
            z = pq.poll();
            y = pq.poll();
            x = pq.poll();
            if (x == y && y!= z) {
                pq.offer(Math.abs(y-z));
            } else if (x!=y&& y==z) {
                pq.offer(Math.abs(y-z));
            } else if (x != y && y!=z) {
                int diff1 = Math.abs(x-y);
                int diff2 = Math.abs(z-y);
                if (diff1!=diff2) {
                    pq.offer(Math.abs(diff1-diff2));
                }
            }
        }
        if (pq.size()>0) {
            return pq.poll();
        }
        return 0;
    }
}
